﻿def basic():
    a = 10
    print (type(a)) 
    print ("3**4=", 3**4)  #3的4次方
    print ("10%3=",10%3)   #取余数
    print ("11//2=",11//2) #取整除数5
    print ("-11//2=",-11//2) #-6

    a = (2,1.2,'lvoe',False,34)  # this is a tuple,once define it can't change
    a = [True,1,2.4,'simple']  # this is a list,we can change it later
    a = {'key1':'Value1','key2':'Value2'} # this is a dictionary,we can change it later    

    #print (dir(list))
    #print (help(list))

    print ( 'ShortInputException: The input was of length %d,was expecting at least %d' % (1, 3) )
    print ( 'ShortInputException: The input was of length {0},was expecting at least {1}'.format(11,33) )

    if isinstance(1,int):
        print ('this is a int')
    else:
        print ('not a int')

    import os,glob
    #[print (f) for f in glob.glob('*.py') if os.stat(f).st_size > 600]

    try:
        s = input('Enter something -> ')
        if len(s) < 3:
            raise ShortInputException(len(s),3)
        a = 234
        b = a
    except ShortInputException as x:
        print ('ShortInputException: The input was of length %d,was expecting at least %d' % (x.length, x.atleast))
    else:
        print ('no exception was raised')
    finally:
        print ('it will always invoke')

    try:
        import cPickle as pickle
    except ImportError:
        import pickle

    print ('Hit Enter to exit...')
    input()
    
def basicfunction():
    #apply(add,(1,2,3) is equal add(1,2,3)
    #cmp(x,y) : 比较x,y的大小,如果x<y则返回负数,相等返回零,大于则返回正数
    #xrange内存上比range好,在于它不存储列表元素,是独立只读向前的,而range会返回所有元素并在内存中进行存储,Python3中统一用range
    import os
    print (os.sep) #返回/或者\,取决于平台

class ShortInputException(Exception):
    '''A user-defined exception class.'''
    def __init__(self,length,atleast):
        Exception.__init__(self)
        self.length = length
        self.atleast = atleast

def textblobbasic():
    from textblob import TextBlob
    print (3)   
    wiki = TextBlob('你说这是一个转账吗？我也不知道')
    wiki.translate(from_lang="zh-CN", to='en')
    t = wiki.tags
    print (wiki.tags) 

if __name__ == "__main__":
    from collections import deque
    print (deque.__mro__)